package com.atguigu.day22.tcpsocket;

import org.junit.Test;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class InetAddressTest {
    @Test
    public void test01() throws UnknownHostException {
        //获取本地主机名和ip
        InetAddress localHost = InetAddress.getLocalHost();
        System.out.println("localHost = " + localHost);//sixfly/192.168.13.22 主机名和ip
    }
    @Test
    public void test02() throws UnknownHostException {
        //获取指定主机的 主机名和ip
        InetAddress byName = InetAddress.getByName("www.atguigu.com");
        System.out.println("byName = " + byName);//www.baidu.com/183.2.172.185
    }
}
